<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="author" content="lzy">
    <title>lzy-</title>
    <script src="jquery-3.1.1.js"></script>
    <style>
        html,body{
            height: 100%;
        }
        body{
            margin: 0;
        }
        #outer{
            width: 300px;
            margin: 0 auto;
            box-shadow: 0 0 2px gray;
        }
        header{
            width: 300px;
            text-align: center;
            border-bottom: 1px solid black;
        }
        main{
            width: 100%;
            text-align: center;
        }
        main img{
            width: 120px;
            height: 75px;
            margin: 5px 10px;
            box-sizing: border-box;
            border: 1px solid lightgray;
            position: absolute;
            left: 0;
            top: 0;
        }
        main div{
            position: relative;
            display: inline-block;
            width: 130px;
            height: 85px;
        }
        main div p{
            position: absolute;
            width: 120px;
            height: 75px;
            background-color: orange;
            top: 30px;
            left: 10px;
            line-height: 75px;
            height: 0;
            opacity: 0;  
            cursor: pointer;     
        }
    </style>
</head>
<body>
    <div id="outer">  
        <header>热门品牌推荐</header>
        <main>
            <div>
                <img src="images/11.jpg" alt="">
                 <p class="p1">翻转</p>
            </div>

            <div>
                <img src="images/22.jpg" alt="">
                 <p class="p2">翻转</p>
            </div>

            <div>
                <img src="images/33.jpg" alt="">
                 <p class="p3">翻转</p>
            </div>

            <div>
                <img src="images/44.jpg" alt="">
                 <p class="p4">翻转</p>
            </div>

            <div>
                <img src="images/55.jpg" alt="">
                 <p class="p5">翻转</p>
            </div>

            <div>
                <img src="images/66.jpg" alt="">
                 <p class="p6">翻转</p>
            </div> 

            <div>
                <img src="images/77.jpg" alt="">
                 <p class="p7">翻转</p>
            </div>

            <div>
                <img src="images/88.jpg" alt="">
                 <p class="p8">翻转</p>
            </div>
        </main>
    </div> 
</body>
</html>
<script>
$('main div').each(function(index){
    $('main div').eq(index).hover(function(){
        $(this).find('img').stop().animate({
            height:0,
            top:35
        },100,function(){
            $(this).next().stop().animate({
                height:75,
                opacity:1,
                top:-10
            },100)
        })
    },function(){
        // console.log(this);
        $('main div').eq(index).stop().find('p').animate({
            height:0,
            opacity:0,
            top:32            
        },100,function(){
            $(this).prev().stop().animate({
                height:75,
                top:0
            },100)
        })        
    })
})





</script>
